package com.yuncommunity.runcircle;

import android.os.Bundle;
import android.widget.TextView;

import com.yuncommunity.runcircle.base.MyActivity;
import com.yuncommunity.runcircle.item.LocationItem;
import com.yuncommunity.runcircle.view.RunDataView;

import java.util.Random;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by oldfeel on 15-12-1.
 */
public class TestActivity extends MyActivity {
    @Bind(R.id.average)
    TextView average;
    @Bind(R.id.max)
    TextView max;
    @Bind(R.id.run_data)
    RunDataView runData;
    @Bind(R.id.day_1)
    TextView day1;
    @Bind(R.id.day_2)
    TextView day2;
    @Bind(R.id.day_3)
    TextView day3;
    @Bind(R.id.day_4)
    TextView day4;
    @Bind(R.id.day_5)
    TextView day5;
    @Bind(R.id.day_6)
    TextView day6;
    @Bind(R.id.day_7)
    TextView day7;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.run_data);
        ButterKnife.bind(this);
        LocationItem[] datas = new LocationItem[7];
        double distance = 0;
        double minDistance = 9999;
        double maxDistance = 0;
        for (int i = 0; i < datas.length; i++) {
            datas[i] = new LocationItem();
            datas[i].distance = new Random().nextDouble() * 10;
            distance += datas[i].distance;
            if (datas[i].distance > maxDistance) {
                maxDistance = datas[i].distance;
            }
            if (datas[i].distance < minDistance) {
                minDistance = datas[i].distance;
            }
        }
        runData.setData(datas, distance / 7, minDistance, maxDistance);
        average.setText(distance / 7 + "");
        max.setText(maxDistance + "");
    }
}
